import { getToken } from '@/utils/auth'

const user = {
  state: {
    token: getToken(),
    name: '',
    avatar: '',
    roles: []
  },

  mutations: {
    SET_TOKEN: (state, token) => {
      state.token = token
    },
    SET_NAME: (state, name) => {
      state.name = name
    },
    SET_AVATAR: (state, avatar) => {
      state.avatar = avatar
    },
    SET_ROLES: (state, roles) => {
      state.roles = roles
    }
  },

  actions: {
    // 登录
    Login ({ commit }, userInfo) {
      return Promise.resolve()
    },

    // 获取用户信息
    GetInfo ({ commit, state }) {
      return Promise.resolve()
    },

    // 登出
    LogOut ({ commit, state }) {
      return Promise.resolve()
    },

    // 前端 登出
    FedLogOut ({ commit }) {
      return Promise.resolve()
    }
  },

  getters: {
    token: state => state.token,
    avatar: state => state.avatar,
    name: state => state.name,
    roles: state => state.roles
  }
}

export default user
